package org.third.spring.hello;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Set;

class AbstractBeanUser {
    private String name;
    private String age;
    private Set<String> urls;
    /**
     * Get the urls value.
     *
     * @return the value of urls
     */
    public Set<String> getUrls() {
        return this.urls;
    }

    /**
     * Set the urls value.
     *
     * @param urls the urls to set
     */
    public void setUrls(Set<String> urls) {
        this.urls = urls;
    }

    private org.springframework.core.io.Resource image;

    public org.springframework.core.io.Resource getImage() {
        return image;
    }

    public void setImage(org.springframework.core.io.Resource image) {
        this.image = image;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    /*
     * (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    public String toString() {
        return "age=" + age + ", name=" + name;
    }

}

public class AbstractBeanTest {
    private static final Logger logger = LoggerFactory.getLogger(AbstractBeanTest.class);

    /**
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        ApplicationContext bf = new ClassPathXmlApplicationContext(AbstractBeanTest.class.getName().replaceAll("\\.", "/") + ".xml");
        UserAndRepresentationFactory ldapUserAndRepFactory1 = (UserAndRepresentationFactory) bf.getBean("ldapUserAndRepFactory1");
        UserAndRepresentationFactory ldapUserAndRepFactory2 = (UserAndRepresentationFactory) bf.getBean("ldapUserAndRepFactory2");
        logger.info(ldapUserAndRepFactory1.toString());
        logger.info(ldapUserAndRepFactory2.toString());

        AbstractBeanUser u1 = (AbstractBeanUser) bf.getBean(AbstractBeanUser.class);
        AbstractBeanUser u2 = (AbstractBeanUser) bf.getBean("AbstractBeanUser");
        logger.info("getBean with class1:" + u1);
        logger.info("getBean with class2:" + u2);
//        logger.info("getBean with class:" + u1.getImage().getFile());
        logger.info("getBean with class:" + u1.getUrls());
        /*
         * AbstractBeanUser AbstractBeanUser1 = (AbstractBeanUser) bf.getBean("AbstractBeanUser");
         * logger.info(AbstractBeanUser1.toString());
         */

        logger.info("ldapUserAndRepFactory1.getOrgService()={}", ldapUserAndRepFactory1.getOrgService());
        logger.info("ldapUserAndRepFactory1.getOrgService()={}", ldapUserAndRepFactory2.getOrgService());
    }
}